var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    array: ['是', '否'],
    date:'',
    index: 0
  },


  onLoad: function (options) {
    var yhq_id = options.id;
    this.setData({
      yhq_id:yhq_id
    })
    this.getYouHuiQuanInfo();
  },

  setTitle:function(e){
    this.setData({
      title:e.detail.value
    })
  },

  setFull:function(e){
    this.setData({
      full:e.detail.value
    })
  },

  setReduce:function(e){
    this.setData({
      reduce:e.detail.value
    })
  },

  getYouHuiQuanInfo:function(){
    var t = this;
    app.visit("huodong/getYouHuiQuanInfo", {
      yhq_id:t.data.yhq_id,
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          info:c.data,
          title:c.data.title,
          full:c.data.full,
          reduce:c.data.reduce,
          date:c.data.yx_time,
          index:c.data.is_chara==2?0:1
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  bindPickerChange: function (e) {
    this.setData({
      seleNulls: '0',
      index: e.detail.value
    })
  },
  bindDateChange: function (e) {
    this.setData({
      seleNull: '0',
      date: e.detail.value
    })
  },

  tijiao:function(e){
    var t = this;
    if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.full))) {
      app.myToast("所猜价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.reduce))) {
      app.myToast("所猜价格只能输入数字！")
    }else{
      app.visit("huodong/setYouHuiQuanInfo", {
        yhq_id:t.data.yhq_id,
        title:t.data.title,
        full:t.data.full,
        reduce:t.data.reduce,
        date:t.data.date,
        index:t.data.index,
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.showToast({
            title: '修改成功',
            icon: 'none',
            success: function () {
              wx.navigateBack();
            }
          })
        }else{
          app.showToast(c.msg)
        }
      })
    }
  },


})